﻿using System;
using System.Net;
using System.Xml.Linq;
using System.Linq;

namespace ArmoryBrowser.Entities
{
    public class Spell
    {
        #region Fields
        private SpellDamageBonuses _bonusDamageField;
        private string _bonusHealingField;
        private HitRating _hitRatingField;
        private SpellCritChance _critChanceField;
        private string _penetrationField;
        private ManaRegen _manaRegenField;
        private HasteRating _hasteRatingField;
        #endregion
        #region Properties
        public SpellDamageBonuses BonusDamage
        {
            get
            {
                return this._bonusDamageField;
            }
            set
            {
                this._bonusDamageField = value;
            }
        }

        public string BonusHealing
        {
            get
            {
                return this._bonusHealingField;
            }
            set
            {
                this._bonusHealingField = value;
            }
        }

        public HitRating HitRating
        {
            get
            {
                return this._hitRatingField;
            }
            set
            {
                this._hitRatingField = value;
            }
        }

        public SpellCritChance CritChance
        {
            get
            {
                return this._critChanceField;
            }
            set
            {
                this._critChanceField = value;
            }
        }

        public string Penetration
        {
            get
            {
                return this._penetrationField;
            }
            set
            {
                this._penetrationField = value;
            }
        }

        public ManaRegen ManaRegen
        {
            get
            {
                return this._manaRegenField;
            }
            set
            {
                this._manaRegenField = value;
            }
        }

        public HasteRating HasteRating
        {
            get
            {
                return this._hasteRatingField;
            }
            set
            {
                this._hasteRatingField = value;
            }
        }
        #endregion
        #region Constructor
        public Spell(XElement element)
        {
            BonusDamage = element.Elements("bonusDamage").Select(e => new SpellDamageBonuses(e)).FirstOrDefault();
            BonusHealing = element.Elements("bonusHealing").Select(e => e.GetAttributeValue("value")).FirstOrDefault();
            HitRating = element.Elements("hitRating").Select(e => new HitRating(e)).FirstOrDefault();
            CritChance = element.Elements("critChance").Select(e => new SpellCritChance(e)).FirstOrDefault();
            Penetration = element.Elements("penetration").Select(e => e.GetAttributeValue("value")).FirstOrDefault();
            ManaRegen = element.Elements("manaRegen").Select(e => new ManaRegen(e)).FirstOrDefault();
            HasteRating = element.Elements("hasteRating").Select(e => new HasteRating(e)).FirstOrDefault();

        }
        #endregion
    }
}
